Exercise 6.1
- Grid approximation evaluates f(θ | y) at a finite, discrete grid of possible θ values by randomly taking a sample of N independent θ values {θ(1), θ(2), …, θ(N)} from the discretized pdf to approximate the full posterior pdf f(θ | y). The algorithm evolves in four steps:
Define a discrete grid of possible θ values.
Evaluate the prior pdf f(θ) and likelihood function L(θ | y) at each θ grid value.
Obtain a discrete approximation of the posterior pdf f(θ | y) by: calculating the product f(θ)L(θ | y) at each θ grid value; and then ormalizing the products so that they sum to 1 across all θ.
Randomly sample N θ grid values with respect to their corresponding normalized posterior probabilities.
- I would change step 1 to specify a discrete grid of reasonable values of the parameter of interest using a plot of the prior pdf and likelihood function so that I could see what ranges of values are implausible (though possible). With this in mind, I’ll set up a discrete grid of λ values between a certain range, essentially truncating the posterior’s tail and making the approximation more accurate.
Exercise 6.2
knitr::include_graphics("image/chain_a.png")

knitr::include_graphics("image/chain_b.png")

knitr::include_graphics("image/chain_c.png")

knitr::include_graphics("image/chain_d.png")
